from django.shortcuts import redirect
from django.utils.deprecation import MiddlewareMixin


class routeGuard(MiddlewareMixin):
    """
    路由保护中间件
    """
    def process_request(self, request):
        if request.path_info in ['/login/', '/register/', '/chartData/']:
            return
        info = request.session.get('username')
        if info:
            return
        return redirect('/login/')
